import { getConfigs, getHomePageInfo } from '../../../services/api';

export default {
  namespace: 'profile',

  state: {
    list: [],
  },

  effects: {
    *fetch({ payload: currentPage }, { call, put }) {
      const response = yield call(getConfigs, currentPage);
      const allData = yield call(getHomePageInfo);
      const { stores, allNewOrder } = allData;
      yield put({
        type: 'save',
        payload: { response, allData, stores, allNewOrder },
      });
    },
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        facilitatorCommissionRatio: payload.response[2],
        allData: payload.allData,
        stores: payload.stores,
        allNewOrder: payload.allNewOrder,
      };
    },
  },
};
